//
//  MyButton.m
//  MeiLiCity
//
//  Created by kwsdzjx on 15/4/23.
//  Copyright (c) 2015年 周佳兴. All rights reserved.
//

#import "MyButton.h"

@implementation MyButton
- (id)init
{
    self = [super init];
    if (self) {
        
        // 1、顶部图片
        self.imageView.contentMode = UIViewContentModeCenter;
        //        [self setImage:[UIImage imageNamed:@"kevin"] forState:UIControlStateNormal];
        //        [self setImage:[UIImage imageNamed:@"kevin1"] forState:UIControlStateSelected];
        
        // 2、设置文字
        self.titleLabel.textAlignment = NSTextAlignmentCenter;
        [self setTitle:@"按钮" forState:UIControlStateNormal];
//        [self setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
//        [self setTitleColor:[UIColor whiteColor] forState:UIControlStateSelected];
    }
    return self;
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/
#pragma mark - 设置按钮内部图片和文字的frame
- (CGRect)imageRectForContentRect:(CGRect)contentRect
{
CGFloat W = contentRect.size.width;
    //    CGFloat H = contentRect.size.height;
    return CGRectMake(0, 10, W, 45);
}
- (CGRect)titleRectForContentRect:(CGRect)contentRect
{
    CGFloat W = contentRect.size.width;
    //    CGFloat H = contentRect.size.height;
    //    CGFloat y = contentRect.size.height;
    return CGRectMake(1, 60, W, 18);
}

@end
